class TopicsController < ApplicationController
	def editTopic
  		@topic = Topic.find(params[:id])
	end
	def update
		  @topic = Topic.find(params[:id])
		  if @topic.update_attributes(params[:topic])
			  @topic.save
			  redirect_to :controller => :topics, :action => :updatePage
		  else render :action => :editTopic
		  end
  end
 def updatePage
end
  def index
		@topics = Topic.find(:all)
	end
	def findR
		@topic = Topic.find(params[:id])
		@replies = @topic.replies
		if @replies.length == 0
			redirect_to :action => :noReplyInTopic, :id => @topic.id

		end
	end
	def backToIndex
		redirect_to :controller => :categories, :action => :index
	end

def newTopic
end
def replyToTopic
	@topic = Topic.find(params[:id])
end
def createTopic
	@topic = Topic.new(params[:topic])
	@category = Category.find(params[:id])
	@category.topics<<@topic
	@topic.save
	redirect_to :controller => :topics, :action=> :backToIndex
end
	def deleteTopic
		 Topic.find(params[:id]).destroy
		 redirect_to :action => 'TopicDeleted'

	end
	def TopicDeleted
	end

end